home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / alsa-base.postinst < prev    next >
Encoding:
Text File  |  2010-10-23  |  2.6 KB  |  86 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. MYNAME="$0"
  6.  
  7. # $* message
  8. warn() { echo "${MYNAME}: Warning: $*" >&2 ; }
  9.  
  10. # $* message
  11. report_error() { echo "${MYNAME}: Error: $*" >&2 ; }
  12.  
  13. udev_is_active()
  14. {
  15.     test -e /dev/.udev.tdb || test -d /dev/.udevdb || return 1
  16.     return 0
  17. }
  18.  
  19. case "$1" in
  20. configure|reconfigure)
  21.     # Decide which conf file to read
  22.     conf_file=""
  23.     if [ -f /etc/default/alsa ] ; then
  24.         conf_file=/etc/default/alsa
  25.     elif [ -f /usr/share/alsa-base/alsa.default ] ; then
  26.         conf_file=/usr/share/alsa-base/alsa.default
  27.     else
  28.         report_error "No configuration file found"
  29.         exit 1
  30.     fi
  31.     # Read variables from conf file
  32.     force_unload_modules_before_suspend="$( 
  33.         . "$conf_file" >/dev/null 2>&1
  34.         echo "$force_unload_modules_before_suspend"
  35.     )"
  36.     # Write new conf file
  37.     cat /usr/share/alsa-base/alsa.default | sed \
  38.         -e "s/force_unload_modules_before_suspend=.*/force_unload_modules_before_suspend=\"${force_unload_modules_before_suspend}\"/" \
  39.         > /etc/default/alsa
  40.     # Run snddevices if required
  41.     # We ignore #309581 "Creating devices not using MAKEDEV violates policy 10.6"
  42.     make_snddevices() { /usr/share/alsa-base/snddevices --no-wipe --owner=root.audio "$@" >/dev/null ; }
  43.     if ! udev_is_active || [ "$WRITE_ON_UDEV" ] ; then
  44.         # static /dev/ or udev-controlled /dev/ that we should write on
  45.         [ -d /dev/snd ] || make_snddevices
  46.     else
  47.         # udev-controlled /dev/ which we shouldn't overwrite
  48.         if [ -d /dev/.static/dev ] && [ -e /proc/mounts ] && grep -qE '^[^ ]+ /dev/\.static/dev' /proc/mounts ; then
  49.             [ -d /dev/.static/dev/snd ] || make_snddevices --dev-dir=/dev/.static/dev > /dev/null
  50.         elif [ -d /.dev ] && [ -e /proc/mounts ] && grep -qE '^[^ ]+ /\.dev' /proc/mounts ; then
  51.             [ -d /.dev/snd ] || make_snddevices --dev-dir=/.dev > /dev/null
  52.         fi
  53.     fi
  54.     # Set up apm symlinks
  55.     [ -f /etc/apm/scripts.d/alsa ] || warn "/etc/apm/scripts.d/alsa is absent"
  56.     # $1: file to check
  57.     already_linked_to_alsa()
  58.     {
  59.         [ "$1" ] || return 1
  60.         [ -L "$1" ] || return 1
  61.         [ "$(basename "$(readlink "$1")")" = alsa ] || return 1
  62.         return 0
  63.     }
  64.     ALREADY_LINKED=no
  65.     for F in /etc/apm/suspend.d/??alsa ; do
  66.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  67.     done
  68.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/suspend.d/80alsa
  69.     ALREADY_LINKED=no
  70.     for F in /etc/apm/resume.d/??alsa ; do
  71.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  72.     done
  73.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/resume.d/20alsa
  74.     ;;
  75. abort-upgrade|abort-remove|abort-deconfigure)
  76.     # We don't have to do anything because we didn't do anything in prerm
  77.     exit 0
  78.     ;;
  79. *)
  80.     echo "postinst called with unknown argument \`$1'" >&2
  81.     exit 1
  82.     ;;
  83. esac
  84.  
  85.  
  86.